package br.sceweb.testeIntegracao;

import static org.junit.Assert.*;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout;

import br.sceweb.dominio.Convenio;
import br.sceweb.dominio.Fachada;
import br.sceweb.servico.DAOFactory;
import br.sceweb.servico.IConvenioDAO;

public class UC05CadastrarConvenio {
	static IConvenioDAO daoConvenio;
	static Convenio convenio;
	static Fachada fachada;
	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		fachada = new Fachada();
		daoConvenio = DAOFactory.getDAOFactory(1).getConvenioDAO();
		convenio = new Convenio();
		convenio.setCnpj("41603025804");
		convenio.setDataInicio("12/10/2014");
		convenio.setDataTermino("15/11/2014");		

	}
	
	@Test
	public void UC05FBCT01CadastraConvenio_com_sucesso() {
		
		assertEquals("Cadastro realizado com sucesso",daoConvenio.cadastra(convenio));
	
	}
	
	public void UC05FBCT02CadastraConvenio_com_sucesso() {
		daoConvenio.cadastra(convenio);
		
		assertEquals(1,daoConvenio.exclui("41603025804"));
	
	}
	
	@Rule
	 public Timeout globalTimeout = new Timeout(8000); // 10 seconds max per method tested

	
	@AfterClass
	public static void tearDownAfterClass() throws Exception {
		daoConvenio.exclui("41603025804");
		System.out.println("Teste Realizado!");
	}

	


}
